package control; 
import service.UserService;

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.WebServlet;
import java.io.IOException;
 
@WebServlet("/user_delete.action")
public class UserDeleteControl extends HttpServlet {

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String id = request.getParameter("id");
        UserService service = UserService.getInstance();
        int rows = service.deleteUser(Integer.parseInt(id));
        if(rows==0){
            request.setAttribute("delErr","数据删除失败，请联系开发商！");
        }
        response.sendRedirect("./user_list.action");
    }
    
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }
}